<template>
  <div v-if="document.length">
    <div
      v-for="(item,index) in document"
      :key="index"
      class="alert alert-custom alert-outline-light"
      role="alert"
    >
      <div class="alert-text">
        <div
          class="text-wrapper"
          v-html="item.content"
        />
      </div>
      <chmbook
        v-if="item.items && item.items.length"
        :document="children.items"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'Chmbook',
  props: {
    document: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {}
  },
  methods: {
    isDashboard(route) {
      const name = route && route.name
      if (!name) {
        return false
      }
      return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase()
    },
    handleLink(item) {
      const { redirect, path } = item
      if (redirect) {
        this.$router.push(redirect)
        return
      }
      this.$router.push(this.pathCompile(path))
    }
  }
}
</script>

<style lang="scss" scoped>
.text-wrapper {
  white-space: pre-wrap;
}
</style>
